<?php 
    // http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html
?>

<div id="table">
	<table cellspacing="0" cellpadding="0">
	    <tr>
	        <th class="first"><?php echo $this->Paginator->sort('id', 'ID'); ?></th>
	        <th><?php echo $this->Paginator->sort('username', 'Užívateľské meno'); ?></th>
	        <th><?php echo $this->Paginator->sort('userlevel', 'Užívateľská rola'); ?></th>
	        <th class="last">Akcie</th>
	    </tr>
	       <?php foreach($data as $user): ?>
	    <tr class="hov">
	        <td class="first"><?php echo $user['User']['id']; ?> </td>
	        <td><?php echo $user['User']['username']; ?> </td>
	        <td><?php echo $user['User']['userlevel'] == 1 ? 'Admin' : 'Superadmin'; ?> </td>
	        <td class="last actions">
	        	<?php 
	        		echo $this->Html->link(
	        			$this->Html->image(BASE_URL . '/img/edit.gif', array('alt' => 'Edit')), 
	        			array('admin' => true, 'controller' => 'users', 'action' => 'edit', $user['User']['id']),
	        			array('escape' => false, 'class' => 'edit')
	        		);
	        		echo ' &nbsp; ';
	        		echo $this->Html->link(
	        			$this->Html->image(BASE_URL . '/img/delete.gif', array('alt' => 'Deleted')), 
	        			array('admin' => true, 'controller' => 'users', 'action' => 'delete', $user['User']['id']),
	        			array('escape' => false, 'class' => 'delete'),
	        			ARE_YOU_SURE
	        		);
	        		//echo $this->Html->image(BASE_URL . '/img/delete.gif', array('alt' => 'Delete', 'url' => array('admin' => true, 'controller' => 'users', 'action' => 'delete', $user['User']['id'])));
	        		//echo $this->Html->link('Del', array('admin' => true, 'controller' => 'users', 'action' => 'delete', $user['User']['id']), array(), 'Are you sure?');
	        	?> 
	        </td>
	    </tr>
	    <?php endforeach; ?>
	</table>
</div>

<div class="paging">
<?php 
$params = $this->Paginator->params();
if ($params['pageCount'] > 1 ) {
// Shows the page numbers
//echo $this->Paginator->numbers();
echo ' ';
// Shows the prev link
echo $this->Paginator->prev('« Predchádzajúca', null, null, array('class' => 'disabled'));
echo ' ';
// prints X of Y, where X is current page and Y is number of pages
echo $this->Paginator->numbers();//echo $this->Paginator->counter();
echo ' ';
// Shows the next link
echo $this->Paginator->next('Nasledujúca »', null, null, array('class' => 'disabled'));
}
?>
</div>

<?php echo $this->element('limit'); ?>